# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=katana-pd
_pkgname=katana
pkgver=v1.2.2.r89.g8683ed5
pkgrel=1
epoch=1
pkgdesc='Crawling and spidering framework.'
arch=('x86_64' 'aarch64')
groups=('blackarch' 'blackarch-webapp' 'blackarch-scanner')
url='https://github.com/projectdiscovery/katana'
license=('MIT')
depends=()
makedepends=('git' 'go')
source=("git+https://github.com/projectdiscovery/$_pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $_pkgname

  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
  cd $_pkgname

  GOPATH="$srcdir" go mod download
  GOPATH="$srcdir" go build \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-s -w" \
    -o $_pkgname ./cmd/$_pkgname
}

package() {
  cd $_pkgname

  install -Dm 755 $_pkgname "$pkgdir/usr/bin/$_pkgname"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE.md "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

